<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>2016春夏订货会－意见收集系统</title>

<meta name="description" content="User login page" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- basic styles -->

<link
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/bootstrap.min.css"
	rel="stylesheet" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/font-awesome.min.css" />

<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/chosen.css" />
<!--[if IE 7]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

<!-- page specific plugin styles -->

<!-- fonts -->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-fonts.css" />

<!-- ace styles -->

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-rtl.min.css" />


<!-- ace settings handler -->

<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/ace-extra.min.js"></script>

<!--[if lte IE 8]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bt_v3/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

<!--[if lt IE 9]>
		<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/html5shiv.js"></script>
		<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/respond.min.js"></script>
		<![endif]-->
<style type="text/css">


.table td {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	vertical-align: middle;
	text-align: center;
	
}
.tdClass {
	color: red;
	
}
</style>
</head>

<body>
<div class="container-fluid">
  <div class="row">
  	<div class="col-xs-12">
	    <table class="table table-striped table-bordered ">
	    	<tr>
	    		<td colspan="6"><h3>2016春夏订货会-意见收集表（商品）</h3>${sessionScope.userSession.sysUser.nickName }[${sessionScope.userSession.sysUser.company }]</td>
	    	</tr>
	    	
	    	<tr>
	    					<td>
								区域
								&nbsp;&nbsp;
								<select  id="area">
											<option value="">全部</option>
											<option value="总部">总部</option>
											<option value="南区">南区</option>
											<option value="中区">中区</option>
											<option value="北区">北区</option>
								</select>
							</td>
							<td>
								分公司
							</td>
							<td>
								<select id="company" class="chosen-select">
												<option value="">全部</option>
												<option value="总部">总部</option>
								</select>
							</td>
							<td>
								是否填写
							</td>
							<td>
								<select id="isnote">
												<option value="">全部</option>
												<option value="1">是</option>
												<option value="0">否</option>
								</select>
							</td>
							<td>
								分标
								&nbsp;&nbsp;
								<select id="jconf">
												<option value="4">JOEONE</option>
												<option value="3">J1</option>
								</select>
							</td>
	    	</tr>
	    	
	    	<tr>
	    		<td colspan="6">
	    			<div class="input-group">
						<span class="input-group-btn">
							<button type="button" class="btn btn-purple btn-sm" id="btn_search">
								查找
								<i class="icon-search icon-on-right bigger-110"></i>
							</button>
							&nbsp;&nbsp;&nbsp;&nbsp;	
							<button type="button" class="btn btn-purple btn-sm" id="btn_del">
								过滤总表
								<i class="icon-search icon-on-right bigger-110"></i>
							</button>
							&nbsp;&nbsp;&nbsp;&nbsp;	
						</span>
					</div>
				</td>
	    	</tr>
	    	
	    	<!-- 报表 -->
	    	<tr>
	    		<td>序号</td>
	    		<td>区域</td>
	    		<td>分公司</td>
	    		<td>客户代码</td>
	    		<td>客户名称</td>
	    		<td>填写</td>
	    	</tr>
	    	<tbody id="show">
	    	</tbody>
	    </table>
    </div>
  </div>
  
<div class="ace-settings-container" id="ace-settings-container">
						<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
							<i class="icon-cog bigger-150"></i>
						</div>

						<div class="ace-settings-box" id="ace-settings-box">
							

							<div>
								<input type="radio"  id="report_vote1" name="report_vote" />
								<label class="lbl" for="report_vote1"> 意见汇总表</label>
							</div>
							<div>
								<input type="radio"  id="report_vote2" name="report_vote" checked="true"/>
								<label class="lbl" for="report_vote2"> 人员分布表</label>
							</div>
						</div>
					</div><!-- /#ace-settings-container -->
</div>
<form action="${pageContext.request.contextPath}/admin/joeoneCode/downloadStat.do" id="hidden_form">
	<input type="hidden" name="jclassName" id="jclassName" />
	<input type="hidden" name="jclassId" id="jclassId"/>
	<input type="hidden" name="jsubjectName" id="jsubjectName"/>
	<input type="hidden" name="jsubjectId" id="jsubjectId"/>
</form>
	<!-- basic scripts -->
	<!--[if !IE]> -->

	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery-2.0.3.min.js'>"
								+ "<"+"/script>");
	</script>
<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/chosen.jquery.min.js"></script>
	<!-- <![endif]-->

	<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

	<script type="text/javascript">
		if ("ontouchend" in document)
			document
					.write("<script src='${pageContext.request.contextPath}/resources/bt_v3/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>
<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/typeahead-bs2.min.js"></script>


		
		
<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/ace-elements.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/bt_v3/assets/js/ace.min.js"></script>

	<script type="text/javascript">
	
		
		
		function fn_search() {
			
			var data = new Object();
			data['area'] = $('#area').val();
			data['company'] = $('#company').val();
			data['isnote'] = $('#isnote').val();
			data['jconf'] = $('#jconf').val();
			
			$.ajax({
						url : "${pageContext.request.contextPath}/admin/dhVote/getUserStat.do",
						async : true,
						dataType : 'json',
						type : 'POST',
						data : data,
						success : function(rtn, textStatus) {
							var trStr = "";
							var for_workStr = "";
							var companyStr = "";
							var num_user = 0;
							var num_userSel = 0;
							var num_i = 0;
							$.each(rtn.data.listData, function(i, item) {
								
								
								if(for_workStr != item.for_work && i > 0 ){//输出统计行

									trStr += "<tr>";
									trStr += "	<td class='tdClass'>--"+(num_i+1)+"</td>";
									trStr += "	<td class='tdClass'>"+companyStr+"</td>";
									trStr += "	<td class='tdClass'>"+for_workStr+"</td>";
									trStr += "	<td class='tdClass'>总数："+num_user+"</td>";
									trStr += "	<td class='tdClass'>已提交："+num_userSel+"</td>";
									trStr += "	<td class='tdClass'>未提交："+(num_user-num_userSel)+"</td>";
									trStr += "</tr>";
									
									num_user = 0;
									num_userSel = 0;
									num_i += 1;
								}
								
								num_user += 1;
								if(item.sum_isbc > 0){
									num_userSel += 1;
								}
								
								
								trStr += "<tr ac='del'>";
								trStr += "	<td>"+(i+1)+"</td>";
								trStr += "	<td>"+item.company+"</td>";
								trStr += "	<td>"+item.for_work+"</td>";
								trStr += "	<td>"+item.name+"</td>";
								trStr += "	<td>"+item.nick_name+"</td>";
								
								if(item.sum_isbc > 0){
									trStr += "	<td>已填</td>";
								}else{
									trStr += "	<td class='tdClass'>未填</td>";
								}
								
								trStr += "</tr>";


								companyStr = item.company;
								for_workStr = item.for_work;
								
								if(i == rtn.data.listData.length-1){//输出统计行

									trStr += "<tr>";
									trStr += "	<td class='tdClass'>--"+(num_i+1)+"</td>";
									trStr += "	<td class='tdClass'>"+companyStr+"</td>";
									trStr += "	<td class='tdClass'>"+for_workStr+"</td>";
									trStr += "	<td class='tdClass'>总数："+num_user+"</td>";
									trStr += "	<td class='tdClass'>已提交："+num_userSel+"</td>";
									trStr += "	<td class='tdClass'>未提交："+(num_user-num_userSel)+"</td>";
									trStr += "</tr>";
									
									num_user = 0;
									num_userSel = 0;
									num_i += 1;
								}
								
								
								
							}); 
							$("#show").html(trStr);
							
						},
						error : function(jqXHR, textStatus, errorThrown) {
							var sessionstatus=jqXHR.getResponseHeader("sessionstatus");
							if(sessionstatus == "timeout"){
								alert("[timeout]您登陆已经超时，请重新登陆!");
								var req_address = "${pageContext.request.contextPath}/joeone/ipad/index_dhVote.jsp";
								window.location.href  = req_address;
							}
						}
	
			});
		}
		function fn_chck() {
			
			if($(this).attr("id") == "report_vote1"){
				var req_address = "${pageContext.request.contextPath}/joeone/ipad/admin_dhVote.jsp";
				window.location.href  = req_address;
			}else if($(this).attr("id") == "report_vote2"){
				var req_address = "${pageContext.request.contextPath}/joeone/ipad/admin_dhUser.jsp";
				window.location.href  = req_address;
			}
			

		}
		function fn_del() {
			

			$.each($("tr[ac='del']"), function(i,val){  	
						$(this).remove();
						
								
				});
			

		}
		//获取启用的当前 配置
		function fn_getJcom() {
			var data = new Object();
			data['docStatus'] = "10";
			data['pageNo'] = "1";
			data['pageSize'] = "500";
			data['forWork'] = "总部";
			$
					.ajax({
						url : "${pageContext.request.contextPath}/admin/sysUser/list.do",
						async : false,
						dataType : 'json',
						type : 'GET',
						data : data,
						success : function(data, textStatus) {
							$.each(data.data.listData, function(i, item) {
								$("#company").append(
										"<option value='"+item.nickName+"'>"
												+ item.nickName + "</option>");
							});
							
						},
						error : function(jqXHR, textStatus, errorThrown) {
							var sessionstatus = jqXHR
									.getResponseHeader("sessionstatus");
							if (sessionstatus == "timeout") {
								alert("[timeout]您登陆已经超时，请重新登陆!");
								var req_address = "${pageContext.request.contextPath}/joeone/ipad/index_dhVote.jsp";
								window.location.href = req_address;
							}
						}

					});

		}
		$(document).ready(function() {
			fn_getJcom();
			$("#btn_search").bind("click", fn_search);
			$("#report_vote1").bind("click", fn_chck);
			$("#report_vote2").bind("click", fn_chck);
			$("#btn_del").bind("click", fn_del);
			$(".chosen-select").chosen({
				no_results_text: "没有找到匹配项!", 
				placeholder_text : "请输入您要查找的选项!", 
				search_contains: true,
				disable_search_threshold: 2,
				width:"95%"
		    });

		});
	</script>

</body>
</html>